<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #app {
      width: 100%;
      height: 100%;
      
    }

    .fruit {
      width: 600px;
      height: 300px;
      background-color: #ccc;
      margin: 0 auto;
      border-radius: 10px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: start
    }

    .fruit h5 {
      text-align: center;
      width: 100%;
      border-bottom: 1px solid #000;
    }

    .fruit p {
      width: 100%;
      text-align: center;
      margin: 5px;
      border-bottom: 1px solid #000;
    }

    
  </style>
</head>

<body>
  <div id="app">
      <div class="fruit">
        <h5>欢迎光临_vue开发的收银系统_水果店</h5>
        <p>苹果 10 元/斤 , 折扣<8折></p>
        <p>请输入你要购买的斤数 <input v-model="num" type="text"></p>
          <button @click="submit">结账买单</button>
        <p>结账单: 总价:{{total}} 折后价: {{newTotal}} 省了: {{discount}}元  </p>
      </div>   
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        num: 1 ,
        total:10,
        newTotal:8,
        discount:2
      },
      methods: {
        submit () {
          this.total = this.num * 10 
          this.newTotal = this.num * 10* 0.8
          this.discount = this.total - this.newTotal
        }
      }
    })
  </script>

</body>

</html>